home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 October / Enter 10 2006.iso / boot / isolinux / initrd / in / sbin / probe < prev    next >
Encoding:
Text File  |  2003-03-09  |  5.7 KB  |  213 lines

  1. #!/bin/sh
  2. # This is 'probe', a wrapper for using fdisk to gather drive info for
  3. # the Slackware setup scripts.  I hate to bounce this much garbage through
  4. # a tmpdir, but it looks like large variables can make ash crash...
  5.  
  6. # Many thanks to Vincent Rivellino for contributing the patches to support
  7. # Mylex and Compaq RAID controllers.
  8.  
  9. TMP=/var/log/setup/tmp
  10. rm -f $TMP/SeTfdisk
  11.  
  12. # listide major minor hd1 hd2 (2 base devs for major)
  13. list_ide() {
  14.   if [ "$2" = "0" ]; then
  15.     fdisk -l /dev/$3 >> $TMP/SeTfdisk
  16.   elif [ "$2" = "64" ]; then
  17.     fdisk -l /dev/$4 >> $TMP/SeTfdisk
  18.   fi
  19. }
  20.  
  21. list_scsi() {
  22.   # find drive # 0 - 15
  23.   DRV=`expr $1 / 16`
  24.   NUM=`expr $1 % 16`
  25.   if [ ! "$NUM" = "0" ]; then
  26.     return
  27.   fi
  28.   if [ "$DRV" = "0" ]; then
  29.     fdisk -l /dev/sda >> $TMP/SeTfdisk
  30.   elif [ "$DRV" = "1" ]; then
  31.     fdisk -l /dev/sdb >> $TMP/SeTfdisk
  32.   elif [ "$DRV" = "2" ]; then
  33.     fdisk -l /dev/sdc >> $TMP/SeTfdisk
  34.   elif [ "$DRV" = "3" ]; then
  35.     fdisk -l /dev/sdd >> $TMP/SeTfdisk
  36.   elif [ "$DRV" = "4" ]; then
  37.     fdisk -l /dev/sde >> $TMP/SeTfdisk
  38.   elif [ "$DRV" = "5" ]; then
  39.     fdisk -l /dev/sdf >> $TMP/SeTfdisk
  40.   elif [ "$DRV" = "6" ]; then
  41.     fdisk -l /dev/sdg >> $TMP/SeTfdisk
  42.   elif [ "$DRV" = "7" ]; then
  43.     fdisk -l /dev/sdh >> $TMP/SeTfdisk
  44.   elif [ "$DRV" = "8" ]; then
  45.     fdisk -l /dev/sdi >> $TMP/SeTfdisk
  46.   elif [ "$DRV" = "9" ]; then
  47.     fdisk -l /dev/sdj >> $TMP/SeTfdisk
  48.   elif [ "$DRV" = "10" ]; then
  49.     fdisk -l /dev/sdk >> $TMP/SeTfdisk
  50.   elif [ "$DRV" = "11" ]; then
  51.     fdisk -l /dev/sdl >> $TMP/SeTfdisk
  52.   elif [ "$DRV" = "12" ]; then
  53.     fdisk -l /dev/sdm >> $TMP/SeTfdisk
  54.   elif [ "$DRV" = "13" ]; then
  55.     fdisk -l /dev/sdn >> $TMP/SeTfdisk
  56.   elif [ "$DRV" = "14" ]; then
  57.     fdisk -l /dev/sdo >> $TMP/SeTfdisk
  58.   elif [ "$DRV" = "15" ]; then
  59.     fdisk -l /dev/sdp >> $TMP/SeTfdisk
  60.   fi
  61. }
  62.  
  63. # List Mylex RAID device
  64. list_rd() {
  65.   # find drive
  66.   DRV=`expr $2 / 8`
  67.   NUM=`expr $2 % 8`
  68.   if [ ! "$NUM" = "0" ]; then
  69.     return
  70.   fi
  71.   fdisk -l /dev/rd/c$1d$DRV >> $TMP/SeTfdisk
  72. }
  73.  
  74. # List Cpq SMART/2 RAID device
  75. list_ida() {
  76.   # find drive
  77.   DRV=`expr $2 / 16`
  78.   NUM=`expr $2 % 16`
  79.   if [ ! "$NUM" = "0" ]; then
  80.     return
  81.   fi
  82.   fdisk -l /dev/ida/c$1d$DRV >> $TMP/SeTfdisk
  83. }
  84.  
  85. list_cciss() {
  86.   # find drive
  87.   DRV=`expr $2 / 16`
  88.   NUM=`expr $2 % 16`
  89.   if [ ! "$NUM" = "0" ]; then
  90.     return
  91.   fi
  92.   fdisk -l /dev/cciss/c$1d$DRV >> $TMP/SeTfdisk
  93. }
  94.  
  95. list_ataraid() {
  96.   # find drive
  97.   DRV=`expr $2 / 16`
  98.   NUM=`expr $2 % 16`
  99.   if [ "$NUM" = "0" ]; then
  100.      fdisk -l /dev/ataraid/d$DRV >> $TMP/SeTfdisk
  101.   else
  102.      return
  103.   fi
  104. }
  105.  
  106. list_amiraid() {
  107.   # find drive
  108.   DRV=`expr $2 / 16`
  109.   NUM=`expr $2 % 16`
  110.   if [ "$NUM" = "0" ]; then
  111.      fdisk -l /dev/amiraid/ar$DRV >> $TMP/SeTfdisk
  112.   else
  113.      return
  114.   fi
  115. }
  116.  
  117. list_md() {
  118.   echo "/dev/$2  1 2 $1 kk Linux" >> $TMP/SeTfdisk
  119. }
  120.  
  121. if cat /proc/partitions | grep / 1> /dev/null 2> /dev/null ; then # new
  122.   cat /proc/partitions | grep / | while read line ; do
  123.     SMASHED_LINE=$line
  124.     MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '`
  125.     MINOR=`echo $SMASHED_LINE | cut -f 2 -d ' '`
  126.     if [ "$MAJOR" = "3" ]; then
  127.       list_ide $MAJOR $MINOR hda hdb
  128.     elif [ "$MAJOR" = "8" ]; then
  129.       list_scsi $MINOR
  130.     elif [ "$MAJOR" = "9" ]; then
  131.       list_md `echo $SMASHED_LINE | cut -f 3 -d ' ' | tr -d '/'` \
  132.               `echo $SMASHED_LINE | cut -f 4 -d ' '`
  133.     elif [ "$MAJOR" = "22" ]; then
  134.       list_ide $MAJOR $MINOR hdc hdd
  135.     elif [ "$MAJOR" = "33" ]; then
  136.       list_ide $MAJOR $MINOR hde hdf
  137.     elif [ "$MAJOR" = "34" ]; then
  138.       list_ide $MAJOR $MINOR hdg hdh
  139.     elif [ "$MAJOR" = "48" ]; then
  140.       list_rd 0 $MINOR
  141.     elif [ "$MAJOR" = "49" ]; then
  142.       list_rd 1 $MINOR
  143.     elif [ "$MAJOR" = "50" ]; then
  144.       list_rd 2 $MINOR
  145.     elif [ "$MAJOR" = "51" ]; then
  146.       list_rd 3 $MINOR
  147.     elif [ "$MAJOR" = "52" ]; then
  148.       list_rd 4 $MINOR
  149.     elif [ "$MAJOR" = "53" ]; then
  150.       list_rd 5 $MINOR
  151.     elif [ "$MAJOR" = "54" ]; then
  152.       list_rd 6 $MINOR
  153.     elif [ "$MAJOR" = "55" ]; then
  154.       list_rd 7 $MINOR
  155.     elif [ "$MAJOR" = "56" ]; then
  156.       list_ide $MAJOR $MINOR hdi hdj
  157.     elif [ "$MAJOR" = "57" ]; then
  158.       list_ide $MAJOR $MINOR hdk hdl
  159.     elif [ "$MAJOR" = "72" ]; then
  160.       list_ida 0 $MINOR
  161.     elif [ "$MAJOR" = "73" ]; then
  162.       list_ida 1 $MINOR
  163.     elif [ "$MAJOR" = "74" ]; then
  164.       list_ida 2 $MINOR
  165.     elif [ "$MAJOR" = "75" ]; then
  166.       list_ida 3 $MINOR
  167.     elif [ "$MAJOR" = "76" ]; then
  168.       list_ida 4 $MINOR
  169.     elif [ "$MAJOR" = "77" ]; then
  170.       list_ida 5 $MINOR
  171.     elif [ "$MAJOR" = "78" ]; then
  172.       list_ida 6 $MINOR
  173.     elif [ "$MAJOR" = "79" ]; then
  174.       list_ida 7 $MINOR
  175.     elif [ "$MAJOR" = "80" ]; then
  176.       list_ide $MAJOR $MINOR hdm hdn
  177.     elif [ "$MAJOR" = "89" ]; then
  178.       list_ide $MAJOR $MINOR hdo hdp
  179.     elif [ "$MAJOR" = "90" ]; then
  180.       list_ide $MAJOR $MINOR hdq hdr
  181.     elif [ "$MAJOR" = "91" ]; then
  182.       list_ide $MAJOR $MINOR hds hdt
  183.     elif [ "$MAJOR" = "101" ]; then
  184.       list_amiraid $MAJOR $MINOR
  185.     elif [ "$MAJOR" = "104" \
  186.       -o "$MAJOR" = "105" \
  187.       -o "$MAJOR" = "106" \
  188.       -o "$MAJOR" = "107" \
  189.       -o "$MAJOR" = "108" \
  190.       -o "$MAJOR" = "109" \
  191.       -o "$MAJOR" = "110" \
  192.       -o "$MAJOR" = "111" ]; then
  193.       list_cciss $(( $MAJOR - 104 )) $MINOR
  194.     elif [ "$MAJOR" = "114" ]; then
  195.       list_ataraid $MAJOR $MINOR
  196.     fi
  197.   done
  198. else # old format and no RAID:
  199.   if cat /proc/partitions | grep md 1> /dev/null 2> /dev/null ; then
  200.     cat /proc/partitions | grep md | while read line ; do
  201.       SMASHED_LINE=$line
  202.       MAJOR=`echo $SMASHED_LINE | cut -f 1 -d ' '`
  203.       if [ "$MAJOR" = "9" ]; then
  204.         list_md `echo $SMASHED_LINE | cut -f 3 -d ' ' | tr -d '/'` \
  205.                 `echo $SMASHED_LINE | cut -f 4 -d ' '`
  206.       fi
  207.     done
  208.   fi
  209.   fdisk -l >> $TMP/SeTfdisk
  210. fi
  211.  
  212. cat $TMP/SeTfdisk
  213.